//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef __MODVIEW_H__
#define __MODVIEW_H__

typedef enum ModViewState
{
    ModViewState_Available,
    ModViewState_Deleting,
    ModViewState_Deleted,
} ModViewState;

class ModuleView : public ObjectEnumeratorNode, public IModule
{
// Interface functions
//
public:
    CARAPI_(PInterface) Probe(
        /* [in] */ REIID riid);

    CARAPI_(UInt32) AddRef(void);

    CARAPI_(UInt32) Release(void);

    CARAPI Aggregate(
        /* [in] */ AggrType aggrType,
        /* [in] */ PInterface pObject);

    CARAPI GetDomain(
        /* [out] */ PInterface *ppObject);

    CARAPI GetBaseAddress(
        /* [out] */ Address * pBase);

    CARAPI GetEntryPointAddress(
        /* [out] */ Address * pDllMainStartup);

    CARAPI GetMemorySize(
        /* [out] */ MemorySize * pSize);

    CARAPI GetName(
        /* [out] */ WStringBuf * pName);

    CARAPI GetFullPath(
        /* [out] */ WStringBuf * pName);

    CARAPI GetProcAddressByName(
        /* [in] */ AString Name,
        /* [out] */ Address * pAddress);

    CARAPI GetProcAddressByOrdinal(
        /* [in] */ Int32 ordinal,
        /* [out] */ Address * pAddress);

    CARAPI GetResourceSection(
        /* [out] */ Address * pAddress);

    CARAPI GetSectionByName(
        /* [in] */ AString Name,
        /* [out] */ Address * pAddress);

    CARAPI FindResource(
        /* [in] */ WString name,
        /* [in] */ WString type,
        /* [out] */ Address * pAddress,
        /* [out] */ MemorySize * pSize);

// member functions
//
public:
    CARAPI_(PInterface) GetObject();

    ModuleView(CModule * pModule, CProcess *pProcess) :
        m_pModule(pModule),
        m_modviewstate(ModViewState_Available),
        m_pProcess(pProcess)
    {
#ifdef _ELADBGAGENT
        m_bLoadedForDebuger = FALSE;
#endif //_ELADBGAGENT

        m_rModuleList.Initialize();
        assert(pModule);
        pModule->AddRef();
    }

    virtual ~ModuleView();

// member variable
//
public:
    CModule         *m_pModule;
    DLinkNode       m_rModuleList;
    ModViewState    m_modviewstate;

#ifdef _ELADBGAGENT
    Boolean            m_bLoadedForDebuger;
#endif

private:
    CProcess        *m_pProcess;
};

class ModuleViewRef : public DLinkNode
{
public:
    ModuleView *    m_pModuleView;

    ModuleViewRef(ModuleView * pModuleView) : m_pModuleView(pModuleView) { }
};

#endif // __MODVIEW_H__
